package com.sloera.java.common.cloud.config;

import com.sloera.java.common.cloud.feign.FeignRequestHeaderInterceptor;
import feign.RequestInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author liuwangyang
 * @version 1.0
 * @class com.sloera.java.common.cloud.config.FeignConfiguration
 * @date 2020-8-5
 */
@Configuration
@EnableCaching
@Order(Ordered.HIGHEST_PRECEDENCE)
public class FeignConfiguration implements WebMvcConfigurer {

    @Bean
    @ConditionalOnMissingBean
    public RequestInterceptor requestInterceptor() {
        return new FeignRequestHeaderInterceptor();
    }
}
